﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     UserAccount业务接口的实现
    /// 作者：     Wilson
    /// 日期：     2012/1/17
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class UserAccountSqlMapDao : BaseSqlMapDao, AUV5.DAL.Interface.IUserAccountDao
    {
        private static UserAccountSqlMapDao instance = new UserAccountSqlMapDao();

        private UserAccountSqlMapDao()
        {
            //
            // TODO: 此处添加UserAccountSqlMapDao的构造函数
            //
        }

        public static IUserAccountDao GetInstance()
        {
            return instance;
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectUserAccountByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<UserAccount> GetList()
        {
            try
            {
                return ExecuteQueryForList<UserAccount>("SelectUserAccount", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<UserAccount> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<UserAccount>("SelectUserAccountByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="UserAccountID"></param>
        /// <returns></returns>
        public UserAccount GetDetail(System.String useraccountid)
        {
            try
            {
                return ExecuteQueryForObject<UserAccount>("SelectUserAccount", useraccountid) as UserAccount;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="useraccount"></param>
        /// <returns></returns>
        public object Add(UserAccount useraccount)
        {
            //int id = GetId("UserAccount");
            //useraccount.UserAccountID = id;

            try
            {
                return ExecuteInsert("InsertUserAccount", useraccount);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="useraccount"></param>
        /// <returns></returns>
        public int Update(UserAccount useraccount)
        {
            try
            {
                return ExecuteUpdate("UpdateUserAccount", useraccount);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="UserAccountID"></param>
        /// <returns></returns>
        public int Delete(System.String useraccountid)
        {
            try
            {
                return ExecuteDelete("DeleteUserAccount", useraccountid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="useraccount"></param>
        /// <returns></returns>
        public int Delete(UserAccount useraccount)
        {
            try
            {
                return ExecuteDelete("DeleteUserAccount", useraccount.UserAccountID);
            }
            catch
            {
                throw;
            }
        }

        #region##通过条件得到用户帐号
        /// <summary>
        /// 通过条件得到用户帐号
        /// 创建人：Wilson
        /// 创建时间：2012-2-6
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public UserAccount GetUsrAccountByCondition(object objParameters)
        {
            try
            {
                return ExecuteQueryForObject<UserAccount>("SelectUserAccountCondition", objParameters) as UserAccount;
            }
            catch
            {
                throw;
            }
        }
        #endregion
    }
}
